<template>
  <el-row>
    <el-col :span="3"></el-col>
    <el-col :span="18">
      <div>
        <!--查询-->
        <div>
          <el-form-item label="类型" style="display: flex;">
            <el-select v-model="paramObj.type" class="showInfo">
              <el-option label="文学" value="文学"></el-option>
              <el-option label="科学" value="科学"></el-option>
              <el-option label="教育" value="教育"></el-option>
              <el-option label="笔记" value="笔记"></el-option>
            </el-select>
            <el-button @click="findByItem" type="primary" style="margin-left: 40px">按类型查询</el-button>
            <el-button @click="this.$router.push('/')" type="primary">发贴</el-button>
          </el-form-item>
        </div>
        <!--       表格 -->
        <el-table :data="cutObj.content" style="width: 100%;margin-bottom: 20px" border stripe>
          <el-table-column prop="title" label="标题"/>
          <el-table-column prop="type" label="类型"/>
          <el-table-column label="操作">
            <template #default="scope">
              <el-button type="primary" @click="findById(scope.row.noteEsId)">预览</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--     分页   -->
        <el-pagination
            v-model:current-page="paramObj.pageNO"
            v-model:page-size="pageSize"
            background
            layout="prev, pager, next, jumper"
            :total="this.cutObj.totalElements"
            @current-change="findByItem"
        />
        <div style="display: flex;margin-top: 40px" >
          <el-input v-model="info" style="width: 300px;margin-right: 40px"></el-input>
          <el-button @click="findByInfo" type="primary">按内容查询</el-button>
        </div>

      </div>
    </el-col>
    <el-col :span="3"></el-col>
  </el-row>

</template>
<script>
import axios from "axios";
import {ElMessage} from 'element-plus'

export default {
  data() {
    return {
      cutObj: {},
      currentPage: '',
      pageSize: 3,
      paramObj: {pageNO: 1},
      info: ''
    }
  }, methods: {
    findByItem() {
      console.log(this.paramObj.type)
      console.log(this.paramObj);
      axios.get("/project/note/findItem", {params: this.paramObj}).then(r => {
        let info = r.data;
        console.log(info);
        this.cutObj = info;
      })
    }, findById(noteEsId) {
      console.log(noteEsId);
      sessionStorage.setItem("id", noteEsId);
      this.$router.push("/note/noteInfo");
    }, findByInfo() {
      console.log(this.info);
      sessionStorage.setItem("info", this.info);
      this.$router.push('/note/showInfo')


    }
  }, created() {
    this.findByItem();
  }
}
</script>

<style scoped>

</style>